<!DOCTYPE >
<html lang="zh-cn">
<head>
		<title>后台管理-提现</title>
    <% include ./partials/head %>
	<script type="text/javascript">
		var oWithdraw ={
			operator:function(){
				$(".box-content").on('click','.ok',function(){
					$this = $(this)
					if(window.confirm('你确定已经处理过该用户的体现申请了吗？')){
						//认证 0通过，1拒绝
						$.post("/admin/withdraw",{
							"withdrawId":$this.attr('authId'),
							"isWithdraw":0
						},function(json){
							if(json.code==0){
								history.go(0) 
							}else{

							alert(json.msg);
							}
						},'json');
					}else{
						//取消
					}
				}).on('click','.pass',function(){
					$this = $(this)
					if(window.confirm('你确定要拒绝该用户的提现吗？')){
						//拒绝
						$.post("/admin/withdraw",{
							"withdrawId":$this.attr('authId'),
							"isWithdraw":1
						},function(json){
							if(json.code==0){
								history.go(0) 
							}else{
								alert(json.msg);
							}
						},'json');
					}else{
						//取消
					}
				})
			},
			change:function(){
				var state =window.location.href.split("=")[1];
				if(state ==1){
					$(".title_info").html("已处理");
				}else if(state==3){
					$(".title_info").html("已拒绝");
				}else{
					$(".title_info").html("未处理");
				}
				$("#withdraw-filter").on("change",function(){
					var value = $(this).children('option:selected').val(); 
					window.location.href="/admin/withdraw?status="+value;
				})
			},
			init:function(){
				this.operator();
				this.change();
			}
		}
		$(document).ready(function(){
			oWithdraw.init();
		})
	</script>
</head>
<body>
	<header>
      <% include ./partials/header %>
	</header>
  <div class="ch-container">
    <% include ./partials/sidebar %>
    <!-- 页面内容 -->
    <div id="content" class="col-lg-10 col-sm-10">
        <div class="row">
          <div class="box col-md-12">
            <div class="box-inner">
              <div class="box-header well" data-original-title="">
                <div class="control-group">
                  <div class="controls">
                    <label class="control-label" for="selectError">筛选:&nbsp&nbsp&nbsp </label>
                    <select id="withdraw-filter" data-rel="chosen">
                    	<option>选择</option>
                        <option value="0">未处理</option>
                        <option value="2" >已通过</option>
                        <option value="3">已拒绝</option>
                    </select>
                  </div>
                  
                </div>
              </div>

              <div class="box-content">
              	<div class="alert alert-info center title_info"></div>
                <table class="table table-striped table-bordered bootstrap-datatable datatable responsive">
                  <thead>
                    <tr>
                      <th></th>
                      <th>提现人</th>
                      <th>口袋ID</th>
                      <th>支付宝账号</th>
                      <th>账户余额</th>
                      <th>提现金额</th>
                      <th>应付金额</th>
                      <th>提现时间</th>
                      <th>处理情况</th>
                    </tr>
                  </thead>

                  <tbody>
                    <% if (typeof withdraw != "undefined") { %>
                      <% withdraw.forEach(function(withdraw,index) { %>
                        <tr>
                          <td class="center"><%=index%></td>	
                          <td class="center"><a href="/admin/userinfo?userId=<%= withdraw.get('user').id%>"><%= withdraw.get("user").get("nickname") %></a></td>
                          <td class="center"><%= withdraw.get("user").get("molianId") %></td>
                          <td class="center"><%= withdraw.get("alipay_account") %></td>
                          <td class="center"><%= withdraw.get("user").get("balance") %></td>
                          <td class="center"><%= withdraw.get("sum") %></td>
                          <td class="center"><%= withdraw.get("sum") *0.85%></td>
                          <td class="center"><%=Format(new Date(withdraw.createdAt))%></td>
                          <td class="center">
  						    <% if(withdraw.get("status")==1){ %>
					      		<span class="btn">已处理</span>	
					      	<% } %>
					      	<% if(withdraw.get("status")==3){ %>
					      		<span class="btn">已拒绝</span>	
					      	<% } %>
					      	<% if(withdraw.get("status")==0){ %>
					      		<span class="btn btn-success ok " authId=<%=withdraw.id%>>
	                              <i class="glyphicon glyphicon-ok icon-white"></i>
	                             通过 
	                          	</span>
	                          	<span class="btn btn-danger pass" authId=<%=withdraw.id%>>
	                              <i class="glyphicon glyphicon-remove icon-white"></i>
	                             拒绝 
	                          	</span>
					      	<% } %>

                            
                          </td>
                        </tr>
                      <% }) %>
                    <% } %>
                  </tbody>
                </table>
              </div>

            </div>
          </div>
        </div>
      </div>
    <% include ./partials/footer %>
  </div>
  <% include ./partials/external %>
</body>
</html>
